<?php
declare(strict_types=1);
namespace SixShop\Wechat\Hook;

use app\api\event\UserDeletedEvent;
use SixShop\Core\Attribute\Hook;
use SixShop\Wechat\Model\ExtensionWechatUserModel;

class WechatUserHook
{

    #[Hook(UserDeletedEvent::class)]
    public function deleteWechatUser(UserDeletedEvent $event): void
    {
        $user = ExtensionWechatUserModel::where('user_id', $event->userID)->findOrEmpty();
        if ($user->isEmpty()) {
            return;
        }
        $user->delete();
    }
}